<script setup lang="ts">
import type { Hot } from "../hooks/useHot";

interface Props {
  type?: string;
  list?: Array<Hot>;
  height?: number;
}
// props
const props = withDefaults(defineProps<Props>(), {
  type: "",
  list: () => []
});
// emit
const emit = defineEmits(["exchange", "select"]);
</script>

<template>
  <Flex class="hot" justify="flex-start">
    <Flex class="scroll" justify="flex-start">
      <view
        class="item"
        v-for="(item, index) in props.list"
        :key="index"
        @click="emit('select', item.content)"
      >
        <view>
          <image class="icon-hot" src="@/static/hot.png"></image>
          <text class="text">{{ item.content }}</text>
        </view>
        <text class="gz">{{ item.hot_index }}关注</text>
      </view>
    </Flex>
    <Flex class="exchange" @click="emit('exchange')">
      <image src="@/static/Sync.png" />
      换一换
    </Flex>
  </Flex>
</template>

<style lang="scss" scoped>
.hot {
  width: 100%;
  background-color: #f2f4ff;
  box-sizing: border-box;
  padding-top: 3px;
  padding-right: 5px;
}
.scroll {
  flex-grow: 1;
  overflow-x: scroll;
  margin-right: 8px;
  padding: 5px;

  &::-webkit-scrollbar {
    width: 0;
    height: 0;
  }
  .item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    background-color: #fff;
    border-radius: 10px;
    color: #17181c;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
    &:not(:last-child) {
      margin-right: 8px;
    }
  }
  .icon-hot {
    display: inline-block;
    width: 12px;
    height: 12px;
    vertical-align: middle;
  }
  .text {
    display: inline-block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    vertical-align: middle;
    margin-left: 4px;
    font-size: 12px;
    max-width: 205px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .gz {
    font-size: 12px;
    color: #9297b6;
  }
}

.exchange {
  font-size: 12px;
  color: #4059fd;
  flex-shrink: 0;
  image {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 3px;
  }
}
</style>
